package LeetCode.month01.day30;

public class No1004 {
    public int longestOnes(int[] nums, int k) {
        int left = 0;
        int res = 0;
        int n = nums.length;
        int num = 0;
        for (int i = 0; i < n; i++) {
            if(nums[i]==0){
                num++;
            }
            while(num>k){
                if(nums[left]==0){
                    num--;
                }
                left++;
            }
            res = Math.max(res,i-left+1);
        }
        return res;
    }
}
